package com.micro.play.internet.audio.book.domain.controller;

import com.micro.play.internet.audio.book.domain.business.PlayBusiness;
import com.micro.play.internet.audio.book.domain.pojo.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api")
@RestController
public class PlayController {

    @Autowired
    private PlayBusiness playBusiness;

    @PostMapping("/search/books")
    public GlobalResponseEntity<List<SearchBookItemVO>> searchBooksByKeyword(SearchBookParamVO searchBookParam) throws Throwable {
        List<SearchBookItemVO> resultItems = playBusiness.searchBooksByKeyword(searchBookParam);
        return GlobalResponseEntity.success("ok", resultItems);
    }

    @PostMapping("/analyze/catalogs")
    public GlobalResponseEntity<List<AnalyzeBookCatalogItemVO>> analyzeBookCataLogs(AnalyzeBookCatalogParamVO analyzeBookCatalogParam) throws Throwable {
        List<AnalyzeBookCatalogItemVO> resultItems = playBusiness.analyzeBookCataLogs(analyzeBookCatalogParam);
        return GlobalResponseEntity.success("ok", resultItems);
    }

    @PostMapping("/analyze/playUrl")
    public GlobalResponseEntity<List<AnalyzePlayUrlItemVO>> analyzeBookCataLogs(AnalyzePlayUrlParamVO analyzePlayUrlParam) throws Throwable {
        AnalyzePlayUrlItemVO resultItem = playBusiness.analyzePlayUrl(analyzePlayUrlParam);
        return GlobalResponseEntity.success("ok", resultItem);
    }

}
